﻿using System;
using System.Collections.Generic;
using System.Text;

using Obsidian.Utils;
using Obsidian.Edm;

namespace Oak.Model
{
    public class CoSessionInfo : Obsidian.Edm.OModel
    {

        private StringField sessionKey;
        private DateTimeField loginTime;
        private StringField data;
        private IntField expires;
        private DateTimeField accessTime;
        private DateTimeField expiresTime;

        public CoSessionInfo()
        {
            base.InitModel("oak", "CoSessions", new IModelField[]{
                sessionKey = new StringField(this, "SessionKey"),
                loginTime = new DateTimeField(this, "LoginTime"),
                data = new StringField(this, "Data"),
                expires = new IntField(this, "Expires"),
                accessTime = new DateTimeField(this, "AccessTime"),
                expiresTime = new DateTimeField(this, "ExpiresTime")
            });
        }

        public StringField SessionKey { get { return sessionKey; } }
        public DateTimeField LoginTime { get { return loginTime; } }
        public StringField Data { get { return data; } }
        public IntField Expires { get { return expires; } }
        public DateTimeField AccessTime { get { return accessTime; } }
        public DateTimeField ExpiresTime { get { return expiresTime; } }

        public T GetDataModel<T>() where T : IModel, new()
        {
            return ModelUtil.ToModel<T>(this.data.Value);
        }

    }
}
